package com.ruan.service;

import com.ruan.dao.OrdersMapper;
import com.ruan.openfeign.AddressCenterOpenfeign;
import com.ruan.openfeign.UserCenterOpenfeign;
import com.ruan.pojo.Orders;
import com.ruan.query.OrdersQuery;
import com.ruan.vo.OrdersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName:OrdersService
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/6/20 11:21
 **/
@Service
public class OrdersService {

    @Autowired
    private OrdersMapper ordersMapper;
    @Resource
    private UserCenterOpenfeign userCenterOpenfeign;
    @Resource
    private AddressCenterOpenfeign addressCenterOpenfeign;

    public List<OrdersVo> getOrdersList(OrdersQuery ordersQuery) {

        List<OrdersVo> ordersList = ordersMapper.getOrdersList(ordersQuery);

        for(OrdersVo i:ordersList){

            i.setUserName(userCenterOpenfeign.getUserById(i.getUserId()).getUserName());

            i.setAddressName(addressCenterOpenfeign.getAddressById(i.getAddressId()).getAddressName());

        }

        return ordersList;

    }
}
